﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

using ProjectBase.Core;
using ProjectBase.Core.Web;

namespace $safeprojectname$.Services
{
    /// <summary>
    ///     Entity Node.
    /// </summary>
    [Serializable]
    public class StoryNode : ITVDataItem
    {
        #region members
        IEnumerable<ITVDataItem> _items = new List<ITVDataItem>();
        IDictionary<string, object> _routeValues = new Dictionary<string, object>();
        string _text;
        #endregion members

        #region Dynamic text
        public virtual Func<string> Expression { get; set; }
        #endregion Dynamic text

        #region ITVDataItem
        public virtual string ID { get; set; }
        public virtual string ParentId { get; set; }

        public virtual string Text
        {
            get
            {
                if (_text.IsNull()
                    && Expression.Is())
                {
                    return Expression.Invoke();
                }
                return _text;
            }
            set { _text = value; }
        }

        public virtual string Href { get; set; }

        string ITVDataItem.ImagePath
        {
            get { return ImagePath; }
        }
        protected virtual string ImagePath
        {
            get { return string.Empty; }
        }

        public virtual IEnumerable<ITVDataItem> Items
        {
            get { return _items; }
            set { _items = value; }
        }

        public virtual IDictionary<string, object> RouteValues
        {
            get { return _routeValues; }
            set { _routeValues = value; }
        }
        #endregion ITVDataItem
    }
}